#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

template <typename E>
void printVector(const std::vector<E> &v)
{
    for (const E &i : v)
    {
        std::cout << i << " ";
    }
    std::cout << std::endl;
}

int main(int argc, char const *argv[])
{
    srand(time(0));
    std::set<int> set{};
    for (int i = 0; i < 10; i++)
    {
        set.insert(rand() % 100);
    }

    std::vector<int> vector = std::vector<int>(set.begin(), set.end());
    printVector(vector);

    std::set<int> set2{};
    for (int i = 0; i < 10; i++)
    {
        set2.insert(rand() % 100);
    }

    std::for_each(set2.begin(), set2.end(), [](const int &i)
                  { std::cout << i << " "; });
    std::cout << std::endl;

    std::vector<int> vector2 = {set2.begin(), set2.end()};
    printVector(vector2);
    std::vector<int> mergeVector;
    mergeVector.resize(set.size() + set2.size());
    std::merge(set.begin(), set.end(), set2.begin(), set2.end(), mergeVector.begin()); // set 也可以直接排序
    // std::merge(vector.begin(), vector.end(), vector2.begin(), vector2.end(), mergeVector.begin());
    printVector(mergeVector);

    return 0;
}
